#ifndef __LCD_H__
#define __LCD_H__

#include <rtthread.h>
#include "board.h"


#define LCD_W 240
#define LCD_H 135

#define	u8 unsigned char
#define	u16 unsigned int
#define	u32 unsigned long


#define LCD_SCL     28  /* D20 */
#define LCD_SDA     27  /* D19 */
#define LCD_RES     25  /* D17 */
#define LCD_DC      29  /* D21 */
#define LCD_CS      26  /* D18 */
#define LCD_BL      43

//-----------------LCD端口定义---------------- 

#define LCD_SCLK_Clr() rt_pin_write(LCD_SCL,PIN_LOW)//SCL
#define LCD_SCLK_Set() rt_pin_write(LCD_SCL,PIN_HIGH)

#define LCD_SDIN_Clr() rt_pin_write(LCD_SDA,PIN_LOW)//DIN
#define LCD_SDIN_Set() rt_pin_write(LCD_SDA,PIN_HIGH)

#define LCD_RES_Clr() rt_pin_write(LCD_RES,PIN_LOW)//RES
#define LCD_RES_Set() rt_pin_write(LCD_RES,PIN_HIGH)

#define LCD_DC_Clr() rt_pin_write(LCD_DC,PIN_LOW)//DC
#define LCD_DC_Set() rt_pin_write(LCD_DC,PIN_HIGH)

#define LCD_CS_Clr()  rt_pin_write(LCD_CS,PIN_LOW)//CS
#define LCD_CS_Set()  rt_pin_write(LCD_CS,PIN_HIGH)

#define LCD_BLK_Clr()  rt_pin_write(LCD_BL, PIN_LOW)
#define LCD_BLK_Set()  rt_pin_write(LCD_BL, PIN_HIGH)

#define LCD_CMD  0	//写命令
#define LCD_DATA 1	//写数据

extern  u16 BACK_COLOR;   //背景色

void LCD_Writ_Bus(u8 dat);
void LCD_WR_DATA8(u8 dat);
void LCD_WR_DATA(u16 dat);
void LCD_WR_REG(u8 dat);
void LCD_Address_Set(u16 x1,u16 y1,u16 x2,u16 y2);
void Lcd_Init(void);
void LCD_Clear(u16 Color);
void LCD_ShowChinese(u16 x,u16 y,u8 index,u8 size,u16 color);
void LCD_DrawPoint(u16 x,u16 y,u16 color);
void LCD_DrawPoint_big(u16 x,u16 y,u16 colory);
void LCD_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color);
void LCD_DrawLine(u16 x1,u16 y1,u16 x2,u16 y2,u16 color);
void LCD_DrawRectangle(u16 x1, u16 y1, u16 x2, u16 y2,u16 color);
void Draw_Circle(u16 x0,u16 y0,u8 r,u16 color);
void LCD_ShowChar(u16 x,u16 y,u8 num,u8 mode,u16 color);
void LCD_ShowString(u16 x,u16 y,const u8 *p,u16 color);
u32 mypow(u8 m,u8 n);
void LCD_ShowNum(u16 x,u16 y,u16 num,u8 len,u16 color);
void LCD_ShowNum1(u16 x,u16 y,float num,u8 len,u16 color);
void LCD_ShowPicture(u16 x1,u16 y1,u16 x2,u16 y2);

// #define SET_RGB_COLOR(R,G,B)    (((R)<<11) | ((G)<<5) | (B))
#define SET_BGR_COLOR(B,G,R)    (~(((B)<<11) | ((G)<<5) | (R))) /* 5/6/5 : B(0-31)/G(0-64)/0-31*/

//画笔颜色
#define WHITE         	 SET_BGR_COLOR(31,63,31)
#define BLACK         	 SET_BGR_COLOR(0,0,0)
#define BLUE           	 SET_BGR_COLOR(31,0,0)
#define BRED             (~0XF81F)
#define GRED 			 SET_BGR_COLOR(0,63,0)
#define GBLUE			 (~0X07FF)
#define RED           	 SET_BGR_COLOR(0,0,31)
#define MAGENTA       	 (~0xF81F)
#define GREEN         	 (~0x07E0)
#define CYAN          	 (~0x7FFF)
#define YELLOW        	 (~0xFFE0)
#define BROWN 			 (~0XBC40) //棕色
#define BRRED 			 (~0XFC07) //棕红色
#define GRAY  			 (~0X8430) //灰色
//GUI颜色

#define DARKBLUE      	 (~0X01CF)	//深蓝色
#define LIGHTBLUE      	 (~0X7D7C)	//浅蓝色  
#define GRAYBLUE       	 (~0X5458) //灰蓝色
//以上三色为PANEL的颜色 
 
#define LIGHTGREEN     	 (~0X841F) //浅绿色
#define LGRAY 			 (~0XC618) //浅灰色(PANNEL),窗体背景色

#define LGRAYBLUE        (~0XA651) //浅灰蓝色(中间层颜色)
#define LBBLUE           (~0X2B12) //浅棕蓝色(选择条目的反色)
				  		 
#endif   		     



